<template>
      <!-- table -->
  <section class="oa-form__table" v-if="approve.id == 29 || approve.approve_id == 29">
    <h5>{{approve.name}}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>{{approve.name}}<span v-if="approve && approve.code">{{approve.code}}</span></td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">
            新建{{approve.name}}
          </span>
          <span v-else>
            {{approve.approve_name}}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{approve.name}}</span>
      <span v-else>
            {{approve.approve_name}}
      </span>
    </h3>
    <table cellpadding="0" cellspacing="0">
      <tr>
        <td class="_name">申请人</td>
        <td>
          <el-select v-model="value" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
          </td>
        <td class="_name">部门</td>
        <td>
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td class="_name">申请日期</td>
        <td>{{applyTime}}</td>
      </tr>
      <tr>
        <td class="_name">发放单位</td>
        <td colspan="3">
          <el-input  placeholder="发放单位"  v-model="obj.a883" :disabled="$route.query.from != 'new'" />
        </td>
        <td class="_name">人数</td>
        <td>
          <el-input  placeholder="人数" type="number"  v-model="obj.a884" :disabled="$route.query.from != 'new'" />
        </td>
      </tr>
      <tr>
        <td class="_name">工资说明</td>
        <td colspan="5" :title="obj.a885">
          <el-input  placeholder="工资说明" type="textarea"  v-model="obj.a885" :disabled="$route.query.from != 'new'" />
        </td>
      </tr>
      <tr>
        <td class="_name">申请金额</td>
        <td colspan="3">
          <el-input  placeholder="申请金额" type="number"  v-model="obj.a886" :disabled="$route.query.from != 'new'" @input="changeMoneyFunc($event)"/>
        </td>
        <td class="_name">大写金额</td>
        <td colspan="5">
          {{obj.a887}}
        </td>
      </tr>
      <tr>
        <td class="_name">支付方式</td>
        <td colspan="5">
          <el-radio-group  v-model="obj.a888" label="是" :disabled="obj.a888Flag">
            <el-radio label="转账">转账</el-radio>
            <el-radio label="现金">现金</el-radio>
            <el-radio label="电汇">电汇</el-radio>
          </el-radio-group>
        </td>
      </tr>
    </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import { getToDayFunc, changeMoney } from '@/utils/domUtils.js'
import history from '../service/components/process'
import files from '../service/components/files'
const obj = {}
for (let i = 883; i <= 888; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: getToDayFunc(),
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    }
  },
  watch: {
    addDofield () {
      this.addDofieldRender()
    }
  },
  mounted () {
    this.obj.a888 = '转账'
    this.$nextTick(() => {
      // this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
    changeMoneyFunc (e) {
      this.obj.a887 = changeMoney(e)
    }
  }
}
</script>
